package com.shanzmoo.db.module.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shanzmoo.db.module.member.domain.query.MemberMerchantIdPageQuery;
import com.shanzmoo.db.module.member.entity.MemberAccountScoreRecordEntity;
import com.shanzmoo.db.module.member.entity.MemberMerchantEntity;
import com.shanzmoo.db.module.member.mapper.MemberAccountScoreRecordMapper;
import com.shanzmoo.db.module.member.service.IMemberAccountScoreRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 会员积分变动记录 服务实现类
 * </p>
 *
 * @author wangyudi
 * @since 2021-03-23
 */
@Service
public class MemberAccountScoreRecordServiceImpl extends ServiceImpl<MemberAccountScoreRecordMapper, MemberAccountScoreRecordEntity> implements IMemberAccountScoreRecordService {
    /**
     *
     * @param memberId
     * @return
     */
    @Override
    public List<MemberAccountScoreRecordEntity> getbyMemberId(Integer memberId) {
        return list(
                new QueryWrapper<MemberAccountScoreRecordEntity>()
                .eq("member_info_id",memberId)
        );
    }

    @Override
    public Page<MemberAccountScoreRecordEntity> getbyMemberIdPage(MemberMerchantIdPageQuery request) {
        return page(
                request.page(),
                new LambdaQueryWrapper<MemberAccountScoreRecordEntity>().eq(MemberAccountScoreRecordEntity::getMemberMerchantId,request.getId())
        );
    }

    @Override
    public Page<MemberAccountScoreRecordEntity> getbyMemberIds(Page page,List<Integer> collect) {
        return page(
                page,
                new LambdaQueryWrapper<MemberAccountScoreRecordEntity>().in(MemberAccountScoreRecordEntity::getMemberMerchantId,collect)
        );
    }
}
